from MEMORY import *
from Register_File import *
from IF import *
from ID import *


def WB(micro_opt:micro_option, rd:int, ex2reg_value, mem2reg_value, RF:register_file):
    if micro_opt.write_ex2reg:
        RF.files[rd].set(ex2reg_value)
    if micro_opt.write_mem2reg:
        RF.files[rd].set(mem2reg_value)
    RF.files[0].set(0)
    return RF
